Assignment_4
Task 1
1: For the last 3 months of 2017, calculate the total Sales by month, for Region 1 and Region 9 in the Customer_Segment, Corporate, and Consumer. This output is Table 1.
| Region | Month | Customer segment | Total sales |
|---|---|---|---|
| Region 1 | 10 | Consumer | 815.790 |
| Region 1 | 10 | Corporate | 295.060 |
| Region 1 | 11 | Consumer | 9480.470 |
| Region 1 | 11 | Corporate | 8564.840 |
| Region 1 | 12 | Consumer | 210.060 |
| Region 1 | 12 | Corporate | 13260.838 |
| Region 9 | 10 | Consumer | 5908.890 |
| Region 9 | 10 | Corporate | 16781.431 |
| Region 9 | 11 | Consumer | 192.330 |
| Region 9 | 11 | Corporate | 5463.130 |
| Region 9 | 12 | Corporate | 9377.647 |
2: Make a plot of the monthly total Sales in Region 1 and Region 13 in 2015, 2016, and 2017. This output is Figure 1.
3: In Figure 1, identify the months where the total Sales in Region 13 is greater than the total Sales in Region 1. This output is Table 2.
| Month | Year | Region 1 | Region 13 |
|---|---|---|---|
| jun | 2015 | 12844.97 | 32306.88 |
| aug | 2015 | 2266.96 | 13985.22 |
| okt | 2015 | 11058.13 | 14885.24 |
| nov | 2015 | 13290.26 | 49685.99 |
| des | 2015 | 11048.17 | 19514.99 |
| jan | 2016 | 2362.43 | 10407.92 |
| feb | 2016 | 33085.29 | 55631.95 |
| mai | 2016 | 22068.67 | 22821.70 |
| des | 2016 | 17020.27 | 26889.71 |
| jun | 2017 | 10335.31 | 17430.46 |
4: Find the average Profit per Customer_Segment and Product_Category in 2017, for all regions except Region 3, 5 and 8. What segment produced the highest average profit? This output is Table 3.
| Customer segment | Product category | Average profit |
|---|---|---|
| Small Business | Technology | 544.442933 |
| Corporate | Technology | 413.915696 |
| Home Office | Technology | 271.119368 |
| Consumer | Technology | 223.123188 |
| Corporate | Office Supplies | 164.827620 |
| Consumer | Office Supplies | 107.459323 |
| Small Business | Office Supplies | 93.995230 |
| Home Office | Office Supplies | 71.364500 |
| Consumer | Furniture | 19.551912 |
| Small Business | Furniture | 16.874722 |
| Home Office | Furniture | 7.511408 |
| Corporate | Furniture | -88.222121 |
Task 2
In this task, feel free to use any API or package/library that downloads the data to your session. Use code and download daily stock prices for Exxon Mobil Corporation (XOM), traded at NYSE. The Yahoo! Finance site is a convenient place to find the data . Use the Adjusted closing price from January 4th 2010 as the starting date. And calculate the monthly average using trading volume as a weight, and save this variable as “exxon”.
Use code to download the daily Brent Crude Oil Price from FRED from January 4th 2010 as the starting date. And calculate the monthly arithmetic average. Save the monthly arithmetic average values as “oil”.
In both variables, take December 2022, or 2022:12 for shorthand as a last data point.
Plot both variables, i.e., exxon and oil ” in the same plot window. Here, the x-axis should be the “date” variable. Comment on the plots.
Figure for Exxon share price and Oil price
Exxon’s stock price appears to correlate more closely to the oil price after 2015. We can see that they werent very effected by the drop in oil prices from 2014 to 2015 but after this year, they appear to be prices around the same as a barrel of oil.
Now take “exxon” as a y-variable and “oil” as an x-variable.
Use R’s lm() function. Set the variable on the y-axis and x-axis, and specify the data set.
Call:
lm(formula = exxon ~ oil, data = task2)
Coefficients:
(Intercept) oil
47.7232 0.1271
After “running” the code, how do you interpret the estimated coefficients?
The intercept coefficient shows the estimated value of exxon when oil is equal to 0, but it may now have a practical interpretation in this context since its unlikely for oil price to be 0.
The slope coefficient of 0.1282 means that for every one increase in x, exxon’s value will increase by 0.1282. This means there is a positive linear relationship between oil prices and Exxon’s share price, indicating that higher oil prices are associated with higher share prices for Exxon.